import { TDefenseBressUpgrade } from "../../../../../../Message/Db/Tables/TDefenseBressUpgrade";
import { FilterConst } from "../../../../../component/gconst/FilterConst";
import { ToolTipsManager } from "../../../../../../com/mui/manager/ToolTipsManager";
import { CrossDefenceBlessData } from "../data/CrossDefenceBlessData";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { CrossDefenceBlessItemTips } from "./CrossDefenceBlessItemTips";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { ObjCreate } from "../../../common/ObjCreate";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { GButton } from "../../../../../../com/mui/controls/GButton";
//class CrossDefenceBlessItem
    
    export  class CrossDefenceBlessItem /* flash.display.Sprite */
    {
        constructor(arg1: TDefenseBressUpgrade)
        {
            
            this._curFilters = [FilterConst.colorFilter];
            this._data = arg1;
            this.initView();
            this._btnAdd.addEventListener(flash.events.MouseEvent.CLICK, this.clickUpgradeHandler);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.mouseOverMeHandler);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.mouseOutMeHandler);
            this.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.removedHandler);
            return;
        }

        public removedHandler(arg1: Object /* flash.events.Event */): void
        {
            ToolTipsManager.unregister(this);
            return;
        }

        public get data(): TDefenseBressUpgrade
        {
            return this._data;
        }

        public set blessData(arg1: CrossDefenceBlessData)
        {
            if (this.data == null || arg1.data == null) 
            {
                return;
            }
            this._data = arg1.data;
            LoaderHelp.setBitmapdata(this._data.icon + ".jpg", this._img, 2, 2, 34, 34);
            ToolTipsManager.unregister(this);
            ToolTipsManager.register(this, CrossDefenceBlessItemTips, arg1);
            return;
        }

        public set canUpgrade(arg1: Boolean)
        {
            this._canUpgrade = arg1;
            this._btnAdd.visible = this._canUpgrade;
            return;
        }

        public set actived(arg1: Boolean)
        {
            if (arg1) 
            {
                this._curFilters = [];
            }
            else 
            {
                this._curFilters = [FilterConst.colorFilter];
            }
            this._img.filters = this._curFilters;
            return;
        }

        protected initView(): void
        {
            var loc1=GlobalClass.getBitmap(ImagesConst.PackItemBg);
            addChildAt(loc1, 0);
            this._img = new Object /* flash.display.Bitmap */();
            this.addChild(this._img);
            this._btnAdd = ObjCreate.createGButton("", 19, 19, 21, 21, this, "RedAddButton");
            this._btnAdd.visible = false;
            return;
        }

        protected clickUpgradeHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this._canUpgrade) 
            {
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossDefenceBlessUpgradeReq, this._data));
            return;
        }

        protected mouseOverMeHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._img.filters = [FilterConst.worldMapFilter].concat(this._curFilters);
            return;
        }

        protected mouseOutMeHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._img.filters = this._curFilters;
            return;
        }

        protected /* var */_data: TDefenseBressUpgrade;

        protected /* var */_canUpgrade: Boolean;

        protected /* var */_curFilters: Array<any>;

        protected /* var */_btnAdd: GButton;

        protected /* var */_img: Object /* flash.display.Bitmap */;
    }
